<?php
/**
 * 视频管理模块
 * @copyright reginx.com
 * $Id$
 */
class vod_mod extends admin_mod {

    /**
     * 新增视频
     *
     */
    public function addAct(){
        $this->assign('player' , config_lib::$player);
        $plist = core::getobj('cat_tab')->getslist( 0 , 0 , 1);
        $rlist = core::getobj('cat_tab')->getslist( 0 , 2 , 1);
        $this->assign('thumb'  , array($this->conf['thumb_width'] , $this->conf['thumb_height']));
        $this->assign('plist'  , $plist);
        $this->assign('rlist'  , $rlist);
        $id  = intval($this->get('id'));
        if($id > 0){
            $vod = core::getobj('vod_tab')->where("id = $id ")->get();
            $this->assign('vod' , $vod);
            $this->assign('url' , core::getobj('vod_url_tab')->where("vid = $id ")->order('id asc')->getall());
        }
        $this->assign('atitle' , '新增影视');
        $this->display('vod/add.html');
    }

    /**
     * 影视列表页
     *
     */
    public function listAct(){
        $this->assign('atitle' , '影视列表');
        $obj = core::getobj('vod_tab');
        $pobj = new page_lib($obj->count() , 'pn' , intval($this->get('pn' , 'R')) , 15);
        $list = $obj->fields("id,name,udate,status,rec,plays,cat,cat_tab.name as catname")->order("udate desc")->leftjoin('cat_tab' , 'cat' , 'id')->limit($pobj->limit)->getall();
        $this->assign('vstatus' , config_lib::$vstatus);
        $this->assign('list' , $list);
        $this->assign('pobj' , $pobj->toarray());
        $this->display('vod/list.html');
    }

    /**
     * 保存
     *
     */
    public function saveAct(){
        $obj = core::getobj('vod_tab');
        if($obj->load('vod')){
            $act = $obj->data['actor'];
            $dir = $obj->data['director'];
            $vid = $obj->data['id'];
            $ret = $obj->save();
            if((int)$ret['code'] === 0){
                $vid = $vid ? $vid : intval($ret['msg']);
                core::getobj('vod_url_tab')->add($vid , $this->get('url' , 'P'));
                $dir != '' && tag_lib::add(1 , $vid , $dir);
                $dir != '' && tag_lib::add(2 , $vid , $act);
                $this->showmsg('操作成功' , NULL , 1 , 2);
            }
        }
        $this->showmsg($obj->geterr() , -1 , 1 , 2);
    }
    
    public function delAct(){
        $id = intval($this->get('id'));
        if($id > 0){
            vod_lib::del($id);
        }
        $this->showmsg('操作成功' , NULL , 1 , 2);
    }

    /**
     * 播放地址批量新增mini页面
     *
     */
    public function urlAct(){
        $this->assign('player' , config_lib::$player);
        $this->display('vod/url.html');
    }

    /**
     * 杂项信息编辑mini页面
     *
     */
    public function miscAct(){
        $this->display('vod/misc.html');
    }

    /**
     * 演职员信息
     *
     */
    public function actorAct(){
        $this->assign('vs' , config_lib::$vstatus);
        $this->assign('vlang' , config_lib::$vlang);
        $this->display('vod/act.html');
    }

    /**
     * SEO 相关
     *
     */
    public function seoAct(){
        $this->assign('tpls' , vod_lib::gettpl(0));
        $this->display('vod/seo.html');
    }

    /**
     * 内容介绍
     *
     */
    public function infoAct(){
        $this->display('vod/info.html');
    }
}
?>